package net.da.core.bof.spi.local;

import java.util.Collection;

import net.da.core.bof.OrganizationUnit;
import net.da.core.bof.OrganizationUser;
import net.da.core.entity.OrganisationUnitEntity;

public class OrganizationUnitImpl<E extends OrganisationUnitEntity> extends
        BusinessObjectImpl<OrganisationUnitEntity> implements OrganizationUnit {

    public OrganizationUnitImpl() {
        super();
    }

    public OrganizationUnitImpl(OrganisationUnitEntity entity) {
        super(entity);
    }

    public OrganisationUnitEntity getEntity() {
        return (OrganisationUnitEntity) super.getEntity();
    }

    public Class getEntityClass() {
        return OrganisationUnitEntity.class;
    }

    public Collection<OrganizationUser> getOrganisationUsers() {
        return businessObjectManager.getBusinessObjectsByEntities(OrganizationUser.class, getEntity().getOrganisationUsers());
    }

    public String getAddress() {
        return getEntity().getAddress();
    }

    public String getName() {
        return getEntity().getName();
    }

    public void setAddress(String address) {
        getEntity().setAddress(address);
    }

    public void setName(String name) {
        getEntity().setName(name);
    }

    public void addOrganisationUser(OrganizationUser organizationUser) {
        getEntity().getOrganisationUsers().add(((OrganizationUserImpl) organizationUser).getEntity());
    }

    public void removeOrganisationUser(OrganizationUser organizationUser) {
        getEntity().getOrganisationUsers().remove(((OrganizationUserImpl) organizationUser).getEntity());
    }

    public void removeAllOrganisationUsers() {
        getEntity().getOrganisationUsers().clear();
    }

}
